<?php

namespace Packages\Authority\Services;

use App\Tools\Common;
use Packages\Authority\Repositories\AuthInfoRepositories;
use Packages\Authority\Repositories\RoleInfoRepositories;
use Packages\Authority\Repositories\RelUserRoleRepositories;
use Packages\Authority\Repositories\RelRoleAuthRepositories;
use Exception;

class AuthorityService
{

    public AuthInfoRepositories $auth;
    public RoleInfoRepositories $role;
    public RelUserRoleRepositories $userRole;
    public RelRoleAuthRepositories $roleAuth;

    /**
     * 构建函数
     *
     */
    public function __construct(
        AuthInfoRepositories $auth,
        RoleInfoRepositories $role,
        RelUserRoleRepositories $userRole,
        RelRoleAuthRepositories $roleAuth
    ) {
        $this->auth = $auth;
        $this->role = $role;
        $this->roleAuth = $roleAuth;
        $this->userRole = $userRole;
    }

    /********************** 业务逻辑层 *********************/

    /**
     * 获取角色权限信息
     *
     */
    public function roleAuthAllInfo($role_id)
    {
        // 获取角色关联权限 Id
        $authIds = $this->roleAuth->roleAuthAllId($role_id);

        // 查询权限信息
        return $this->auth->all(['guids' => $authIds]);
    }
}
